<?php

/*
**	Home
**	The home page displays all blog posts.
**
*/

$data['applicationTitle'] = $this->lang->line('ligature_title');;
$data['pageTitle'] = $this->lang->line('ligature_home_title');
$data['pageId'] = 'home';

$data['message'] = $this->session->flashdata('message');

$postCount  = $this->Ligature_Post_model->postCount();
$perPage    = 25;
$lastPage   = floor($postCount / $perPage) + 1;

if (!isset($currentPage) || is_null($currentPage) || !is_numeric($currentPage)) {
    // show first page
    $currentPage = 1;
} elseif (($currentPage - 1) * $perPage > $postCount) {
    // current page beyond number of posts, show last page
    $currentPage = $lastPage;
}

$data['allPosts'] = $this->Ligature_Post_model->listPost($currentPage, $perPage);
$data['hasEarlierPosts'] = ($currentPage < $lastPage);
$data['hasLaterPosts'] = ($currentPage > 1);
$data['currentPage'] = $currentPage;

$data['recentComments'] = $this->Ligature_Comment_model->listComment(1, 10);

$data['currentUserName'] = $this->session->userdata('current_user_name');

$this->load->view($this->config->item('theme', 'ligature') . '/header', $data);
$this->load->view($this->config->item('theme', 'ligature') . '/home', $data);
$this->load->view($this->config->item('theme', 'ligature') . '/footer', $data);

/* clickframes::version=3483667068::clickframes */
?>